<?php
/**
 * Created by PhpStorm.
 * User: lingyun
 * Date: 2018/2/28
 * Time: 11:33
 * Desc: 切换门店
 */
namespace app\index\controller;
use think\Controller;
use think\Db;

class Changestore extends Controller{
    /**
     * @Author  lingyun
     * @Desc    切换城市
     * 2018-03-29
     */
    public function index(){
        //当前的选择的城市
        $city_key = cookie('city_key');
        if(!empty($city_key)){
            $city = db('city')->where('key',$city_key)->value('value');
        }else{
            $city = '';
        }

        $list = get_city();

        $this->assign('city',$city);
        $this->assign('list',$list);
        return $this->fetch('index');
    }

    /**
     * @Author  lingyun
     * @Desc    获取选中的门店列表
     * 2018-03-29
     */
    public function get_store(){
        $city_key = input('city_key');
        $list = get_store($city_key);
        cookie('city_key',$city_key,15552000);
//        $this->assign('list',$list);
        !empty($list)?$this->success('查询成功','',$list):$this->error('找不到门店信息','','');

//        return $this->fetch('get_store');
    }

    /**
     * @Author  lingyunq
     * @Desc    选择门店
     * 2018-03-29
     */
    public function choose_store(){
        $store_id = input('store_id');
        session('store_id',$store_id);
        cookie('store_id',$store_id,15552000);
        $this->success('成功','');
//        $this->redirect('Index/index');
    }

}